package net;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author Andrea
 */
public class ScoreDB implements AutoCloseable{
    
    private Connection connection;
    
    @SuppressWarnings("ResultOfObjectAllocationIgnored")
    private ScoreDB() {
        try {
            String url = "jdbc:mysql://localhost:3306/";
            String dbName = "highscore";
            String driver = "com.mysql.jdbc.Driver";
            String userName = "guest";
            String password = "guest";
            
            new com.mysql.jdbc.Driver();
            
            connection = DriverManager.getConnection(url+dbName, userName, password);
            
        } catch (SQLException ex) {
            Logger.getLogger(ScoreDB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    @Override
    public void close() throws SQLException{
        connection.close();
    }
}
